<template>
  <div class="totalScoreView"> 
    <head-Menu></head-Menu>
    <div class="TSVContainer">
      <el-table :data="EFList" style="width:calc(100% - 10px);max-height:610px;overflow-y:auto;">
        <el-table-column width="300px" label="考试文件" show-overflow-tooltip>
          <template slot-scope="scope">{{EFList[scope.$index]}}</template>
        </el-table-column>
        <el-table-column label="考试班级" show-overflow-tooltip>
          <template slot-scope="scope">{{classesList[scope.$index]}}</template>
        </el-table-column>
        <el-table-column width=160 >
          <template  slot-scope="scope">
            <span v-if="canView == 'true'">
              <el-button @click="toTotalScoreTable(scope.row)" type="primary" icon='el-icon-edit' size="medium" round>查看成绩表</el-button>
            </span>
            <span v-else>
            <el-button type="primary" icon='el-icon-edit' size="medium" disabled round>暂无成绩表</el-button>
            </span>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import headMenu from '../../components/headMenu.vue'
import { getExamFile, getAllExamInf } from "../../api/user";
import { Toast } from "vant";
export default {
  data() {
    return {
      EFList: [],
      classesList: [],
      canView: [],
    }
  },
  components: {
    headMenu
  },
  props: {
    params: {
        type: Object,
        default:{}
    }
  },
  created() {
    this.getExamFile()
  },
  methods: {
    async getExamFile() {
      await getExamFile()
        .then((res) => {
          console.log(res);
          this.EFList = res.examFileName
          this.classesList = res.classesList
          this.getAllExamInf(res.examList)
        })
    },
    async getAllExamInf(examList) {
      await getAllExamInf({
        examFileName: this.EFList,
        classesList: this.classesList,
        examList,
      })
        .then((res) => {
          this.canView = res.canView
        })
    },
    toTotalScoreTable(row) {
      sessionStorage.setItem('toTotalScoreTable', JSON.stringify({ examFileName: row }))
      this.$router.push({
        path:'/teacher/totalScoreTable',
      })
    },
  },
}
</script>

<style lang='stylus'>
.totalScoreView
  flex 1 1 100%
  display block
  .TSVContainer
    margin 0 10px
    border 1px solid #CCCCCC  
    text-align center
    .EFList
      margin-left 10px
      font-weight 600
      font-size 16px
      font-family '黑体'
</style>